local scene = gamestate.new()
local socket = require("socket")
local function GetAdd(hostname)
    local ip, resolved = socket.dns.toip(hostname)
    local ListTab = {}
    for k, v in ipairs(resolved.ip) do
        table.insert(ListTab, v)
    end
    return ListTab
end
local hostname = GetAdd(socket.dns.gethostname())
local ui = {
	ipLabel = {text = "IP:"},
	ipInput = {text = (hostname[2] or hostname[1]),mono = true},
	portLabel = {text = "Port:"},
	portInput = {text = "12345"}
}	

local font = love.graphics.newFont(20)
function scene:enter(from,game)
   	self.game =game
end

function scene:update(dt)
	love.graphics.setFont(font)
	local s = ui.ipLabel
	suit.Label(s.text,s,150,100,100,30)
	local s = ui.ipInput
	suit.Input(s,s,250,100,200,30)
	local s = ui.portLabel
	suit.Label(s.text,s,150,150,100,30)
	local s = ui.portInput
	suit.Input(s,s,250,150,200,30)
	SERVER_IP = ui.ipInput.text
	SERVER_PORT = ui.portInput.text
	self.game:update(dt)
end

function scene:draw()
	self.game:draw()
	suit.draw()
end

function scene:keypressed(k)
	if k == "escape" then
		gamestate.switch(gameState.title,self.game)
	end
end

return scene